Fix PHP 8.5 deprecations: roman_year nullable + (double)→(float) cast#2
Fix PHP 8.5 deprecations: roman_year nullable + (double)→(float) cast#2luca9692 wants to merge 2 commits into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR addresses PHP 8.5 deprecation notices by updating two helper functions in the support library to use canonical/explicit typing and casting syntax.
Changes:
- Update
roman_year()to explicitly accept nullable input (?int $year = null) to avoid deprecation for non-nullable typed params withnulldefaults. - Replace deprecated
(double)$valuecast with canonical(float)$valueinisIntegerFloatingPoint().
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/datetime.php | Makes roman_year() parameter explicitly nullable to avoid PHP 8.4+ deprecation notices. |
| src/validation.php | Switches (double) to (float) cast in integer-floating-point validation logic for PHP 8.5 compatibility. |
Comments suppressed due to low confidence (1)
src/datetime.php:216
- Now that the parameter is typed as
?int, theis_numeric($year)check is effectively just a null check (ints are always numeric). Using$year === null(or renaming the condition/comment) would make the intent clearer and avoid implying non-int inputs are expected.
function roman_year(?int $year = null): string
{
if (!is_numeric($year)) {
$year = (int)date('Y');
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| && ((int)((float)$value) == $value || (int)$value == $value || strpos(strtoupper((string)$value), | ||
| 'E') === false); |
|
Grazie @luca9692 per il contributo! 🙏 Entrambe le tue fix (
Abbiamo quindi aperto #3 che include le tue modifiche + questi fix aggiuntivi, il bump di sicurezza di PHPUnit ( |
- Support PHP up to 8.5 (php constraint ^7.0|^8.0); tested 8.0-8.5 - New GitHub Actions test matrix (PHP 8.0-8.5); decommission CircleCI/Travis/Scrutinizer - Bump phpunit to ^9.6.33 (security: unsafe deserialization in PHPT coverage, GHSA) - PHP 8.5 deprecation fixes: roman_year ?int, (double)->(float), guard out-of-range int casts in isIntegerFloatingPoint, skip xml_parser_free() on PHP >= 8.0 - Tag network-dependent tests @group network, excluded in CI - README: remove broken Scrutinizer/Travis badges, add Tests badge Incorporates and supersedes #2 (PHP 8.5 deprecation fixes by @luca9692). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
What
Two PHP 8.5 deprecation fixes:
src/datetime.php:212—roman_year(int $year = null)→roman_year(?int $year = null)(PHP 8.4+ requires explicit nullable on non-nullable type with defaultnull)src/validation.php:130—(double)$valuecast →(float)$value(PHP 8.5 deprecates non-canonical(double)cast)Why
Used by gescat-laravel on PHP 8.5 — these surface as runtime
Deprecatednotices and will become fatal in PHP 8.6+.Compatibility
Both changes are semantic no-ops (same behavior, explicit syntax). No breaking changes.
Patches